Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling and logging improvements via re-raising #400

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

grzuy
Copy link

@grzuy grzuy commented Sep 18, 2024

Potential alternative to #398 .

Proof of concept still.

Haven't yet tested how compatible is with earlier elixir/otp versions.

This moves to do something "similar" to what plug_cowboy does in https://github.com/elixir-plug/plug_cowboy/blob/ced253f035f2a07ebed17cfacb64d4f16357a750/lib/plug/cowboy/handler.ex#L21-L23.

defp handle_error(kind, reason, stacktrace, transport, span, opts) do
# TODO: Fix this telementry kind
Bandit.Telemetry.span_exception(span, :exit, reason, stacktrace)
status = reason |> Plug.Exception.status() |> Plug.Conn.Status.code()

if status in Keyword.get(opts.http, :log_exceptions_with_status_codes, 500..599) do
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this conditional would be inside the Bandit.LoggerTranslator. Need a way to access the opts.http from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant